package com.dmcloud.zuul.ratelimit;

import com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.RateLimitUtils;
import com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.properties.RateLimitProperties;
import com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.support.DefaultRateLimitKeyGenerator;
import org.springframework.cloud.netflix.zuul.filters.Route;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by xiaodao
 * date: 2020/3/28
 * 自定义 限流key的生成方式
 */
//@Component
public class MyGenKey extends DefaultRateLimitKeyGenerator {
    private  RateLimitProperties properties;
    private  RateLimitUtils rateLimitUtils;
    public MyGenKey(RateLimitProperties properties, RateLimitUtils rateLimitUtils) {
        super(properties, rateLimitUtils);
    }

    /**
     *
     * @param request 请求
     * @param route 路由方式
     * @param policy 限流方式
     * @return
     */
    @Override
    public String key(HttpServletRequest request, Route route, RateLimitProperties.Policy policy) {
        return super.key(request, route, policy);
    }
}
